/**
 * 
 * LuceneDao.java
 * Defender
 * 2013-11-23
 */
package com.ls.fw.data.search.impl.dao.base;

import java.util.List;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;

import com.ls.fw.data.search.impl.lucene.bean.SearchResult;
import com.ls.fw.data.search.impl.lucene.exception.IndexException;

/**
 * 包含关系：索引(Index) –> 段(segment) –> 文档
(Document) –> 域(Field) –> 词(Term)
 * com.demo.lucene LuceneDao
 * @author Defender
 * 2013-11-23 下午08:34:00
 */
public interface LuceneDao {

	public static final String DEFAULT_PK = "id";
	
	public void addDoc( Document doc) throws IndexException;
	

	public void addDoc( IndexWriter indexWriter,Document doc) throws IndexException;

	
	public void addDoc( IndexWriter indexWriter,List<IndexableField> list) throws IndexException;

	
	
	public void addDoc( List<IndexableField> list) throws IndexException;
	
	
	public void addDocs(IndexWriter indexWriter,List<Document> docs) throws IndexException;
	
	 
	public void addDocs(List<Document> docs) throws IndexException;

	
	public void deleteAllDoc() throws IndexException ;

	
	public void deleteAllDoc(IndexWriter indexWriter) throws IndexException ;
	
	 
	public void deleteDoc(IndexWriter indexWriter,Query ...query) throws IndexException ;

	
	public void deleteDoc(IndexWriter indexWriter,Term ...term) throws IndexException ;
	
	
	public void deleteDoc(Query ...query) throws IndexException ;
	
	
	public void deleteDoc(Term ...term) throws IndexException ;

	
	public IndexReader getIndexReader() throws IndexException;

	public IndexReader getIndexReader(Directory dir) throws IndexException;

	
	public IndexWriter getIndexWriter() throws IndexException;

	
	public IndexWriter getNewIndexWriter(Analyzer analyzer) throws IndexException;

	
	public IndexWriter getNewIndexWriter(Analyzer analyzer,OpenMode openMode) throws IndexException;
	
	
	public IndexWriter getNewIndexWriter(IndexWriterConfig iwc) throws IndexException;

	 
	public TopDocs search(IndexSearcher searcher,Query query,int pageSize)  throws IndexException;

	public TopDocs search(IndexSearcher searcher,Query query,int page,int pageSize)  throws IndexException;
	
	public SearchResult search(Query query,int pageSize)  throws IndexException;

	
	public void updateDoc(IndexWriter indexWriter,Term term,Document doc) throws IndexException ;

	
	public void updateDoc(Term term,Document doc) throws IndexException ;

	
	public void close()throws IndexException ;
	
	public void closeIndexWriter()throws IndexException ;
	
	public void closeIndexReader()throws IndexException ;
	
	public void commit()throws IndexException ;
	
	public void rollback()throws IndexException ;

	public void setAutoCommit(boolean flag)throws IndexException ;
	
	public Analyzer getAnalyzer() ;
	 
	public void setAnalyzer(Analyzer analyzer) ;
	
	public boolean isAutoCommit(); 
	
	public void open()throws IndexException ;
	
	public void open(Directory directory) throws IndexException;
	
	public void open(Directory directory,Analyzer analyzer ) throws IndexException ;
	
	public void open(String indexFilePath,Analyzer analyzer ) throws IndexException ;
	
	public void open(String indexFilePath) throws IndexException;
	
	public boolean isOpen();
	
	public void reOpen()throws IndexException;
	
	public void reOpen(Directory directory) throws IndexException;
	
	public void reOpen(Directory directory,Analyzer analyzer ) throws IndexException ;
	
	public void reOpen(String indexFilePath,Analyzer analyzer ) throws IndexException ;
	
	public void reOpen(String indexFilePath) throws IndexException;

	public void reOpenIndexReader() throws IndexException;

	
}
